﻿Imports JuegosLanBackend

Public Class Insertar
    Public Juegos As Buscar

    Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim negocio As New JuegoNegocio
        Try
            If lblId.Text <> "" Then
                negocio.actualizar(lblId.Text, Me.TxtNombre.Text, Me.TxtVersion.Text, Me.TxtFabrica.Text)
            Else
                negocio.insertar(Me.TxtNombre.Text, Me.TxtVersion.Text, Me.TxtFabrica.Text)
            End If

            Me.Juegos.Muestra.DataSource = ""

            MsgBox("Insertado :D")

            Me.Close()



        Catch ex As Exception


        End Try


    End Sub

    Private Sub Insertar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If lblId.Text <> "" Then
            Dim negocio As New JuegoNegocio
            Dim modelo = negocio.obtener(lblId.Text)
            TxtNombre.Text = modelo.nombre
            TxtVersion.Text = modelo.version
            TxtFabrica.Text = modelo.fabricante
        End If
    End Sub
End Class